package com.kx.smsplatform.util;

import com.kx.smsplatform.vo.ResultVO;
import com.kx.smsplatform.common.enums.InterfaceExceptionEnums;
import com.kx.smsplatform.common.exception.SmsException;

/**
 * 定义返回结果的类型是成功还是失败
 *
 * @Author Sun
 * @Date 2021/7/1 19:40
 */
public class R {
    public static ResultVO OK() {
        ResultVO vo = new ResultVO();
        vo.setCode(0);
        vo.setMessage("接收成功");
        return vo;
    }

    public static ResultVO error(InterfaceExceptionEnums enums) {
        ResultVO vo = new ResultVO();
        vo.setCode(enums.getCode());
        vo.setMessage(enums.getMessage());
        return vo;
    }
    public static ResultVO error(SmsException ex) {
        ResultVO vo = new ResultVO();
        vo.setCode(ex.getCode());
        vo.setMessage(ex.getMessage());
        vo.setData(ex.getData());
        return vo;
    }
}
